package com.irs.irsforum.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author yihuili
 * @since 2020-01-18
 */
@Data
@TableName("forum_post")
public class Post extends Model<Post> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @TableField("title")
    private String title;
    @TableField("content")
    private String content;
    @TableField("user_id")
    private Long userId;
    @TableField("creationTime")
    private Timestamp creationTime;
    @TableField("favoriteNum")
    private Long favoriteNum;
    @TableField("replyNum")
    private Long replyNum;
    @TableField("subject_id")
    private Long subjectId;
    @TableField("problem_id")
    private Long problemId;
    /** 0：不存在 1:存在*/
    @TableField("isExist")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer isExist;
    @TableField("extend")
    private String extend;

    private List<Comment> commentList;

    private String userNickName;

    private String subjectName;

    private String problemName;

    private String problemDescription;

    private String problemImg;

    /**1:收藏 0:未收藏 */
    private Integer isFavorite = 0;

    /**1: 发送者 0;非发送者*/
    private Integer isSender = 0;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Timestamp getCreationTime() {
        return creationTime;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }


    @Override
    public String toString() {
        return "Post{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", userId=" + userId +
                ", creationTime=" + creationTime +
                ", favoriteNum=" + favoriteNum +
                ", replyNum=" + replyNum +
                ", subjectId=" + subjectId +
                ", problemId=" + problemId +
                ", isExist=" + isExist +
                ", extend='" + extend + '\'' +
                ", commentList=" + commentList +
                ", userNickName='" + userNickName + '\'' +
                ", subjectName='" + subjectName + '\'' +
                ", problemName='" + problemName + '\'' +
                ", problemDescription='" + problemDescription + '\'' +
                ", problemImg='" + problemImg + '\'' +
                ", isFavorite=" + isFavorite +
                ", isSender=" + isSender +
                '}';
    }
}
